<template>
	<div>
		<!--升级版本选择-->
		<baseSelect ref="baseSelect" :autoSelect="true" :defaultValue="defaultValue" :optionList="options" @change="changeHandel"></baseSelect>
	</div>
</template>

<script>
	import baseSelect from "@/view/components/select/select";
	import {getInstUpgradeTemplate} from "@/service/swagger/TemplateControoler"
	
	export default {
		components : {
			baseSelect
		},
		props:[
			"defaultValue"
		],
		data(){
			return {
				id: "",//实例id
				options: [],
			}
		},
		methods : {
			initData(id){
				if(id){
					this.id = id;
				}
				getInstUpgradeTemplate({
					id : this.id ,
				}).then(ret=>{
					if(!ret.code &&ret.data){
						let arr = ret.data.map(el=>{
							return {
								value: el.templateId ,
		         	 	label: el.appVersion
							}
						})
						
						this.$refs.baseSelect.asyncUpdateOption(arr)
					}
				})
			},
			
			changeHandel(name ,v){
				this.$emit("change", "versonSelect", v)
			},
			
			reset(){
				this.$refs.baseSelect.reset();
				return this ;
			}
		}
	}
	
</script>

<style>
</style>